<?php
/**
 * LowCalVanilla Functions tests
 *
 * @package Extensions
 * @subpackage test
 * @copyright Damien Lebrun 2007
 * @author Damien Lebrun
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GPLv2
 */

if (!defined('IN_VANILLA')) {
	require('./ini_test.php');

	define('STANDALONE_TEST', 1);
}

/**
 * LowCalVanilla File class tests
 * @package Extensions
 */
class TestFileToServe extends UnitTestCase {

	var $Context;
	var $TestPath;
	var $Time;

	function setUp() {
		$this->Context = new TestContext();
		$this->TestPath = TEST_DIR . '/_files/extensions/Baz/baz.css';
		$this->Time = time() - 10000;
		touch($this->TestPath, $this->Time);
	}

	function testConstructor() {
		$File = new LowCalVanilla_FileToServe(
			$this->Context,
			$this->TestPath);
		$this->assertTrue($File->Path);
	}

	function testGetDetails() {
		$File = new LowCalVanilla_FileToServe(
			$this->Context,
			$this->TestPath,
			'text/css');
		$Details = $File->GetDetails();
		$this->assertTrue(is_array($Details));
		$this->assertEqual(
			gmdate('D, d M Y H:i:s', $this->Time) . ' GMT',
			$Details['Last-Modified']);
		$this->assertEqual($this->Time, $Details['ETag']);
		$this->assertEqual('text/css', $Details['Content-Type']);
		$this->assertFalse(isset($Details['Content-Encoding']));
		$this->assertEqual(10, $Details['Content-Length']);
	}
}

if (defined('STANDALONE_TEST')) {

	$test = new TestFileToServe();
	$test->run(new HtmlReporter());
}